/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EditProductManager;

import java.sql.*;
import DBManager.DBConnection;

/**
 *
 * @author Alex
 */
public class EditProductManager {
     public boolean updateUser(Product newProduct)
    {
        boolean result = false;

        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();

            //Construct SQL Query
            PreparedStatement pstmt =
                conn.prepareStatement("UPDATE products SET synopsis=?,price=?,"
                    + " type=? WHERE title=?");

            //append values for the parameters
            int i=1;
           
               pstmt.setString(i++, newProduct.getSypnosis());
               pstmt.setString(i++, newProduct.getPrice());
               pstmt.setString(i++, newProduct.getType());
               
            //execute SQL statement
            pstmt.executeUpdate();

            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}

        return result;
    }
}
